package com.example.demo.service.impl;

import com.example.demo.dao.ContractDao;
import com.example.demo.entity.Contract;
import com.example.demo.service.ContractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ContractServiceImpl implements ContractService {
    @Resource
    private ContractDao contractDao;

    @Override
    public List<Contract> getAllContractByDesId(String desId) {
        return contractDao.getAllContractByDesId(desId);
    }

    @Override
    public Contract getContractByCode(String conCode) {
        return contractDao.getContractByCode(conCode);
    }

    @Override
    public Integer modifyContractByCode(Contract contract) {
        contract.setStatus(0);
        Integer rel = contractDao.modifyContractByCode(contract);
        return rel;
    }

    @Override
    public Integer addContract(Contract contract) {
        contract.setStatus(0);
        /*if(contract.getUserId()==null || contract.getUserId().equals("")){
            contract.setUserId(0);
        }*/
        return contractDao.addContract(contract);
    }

    @Override
    public Contract getContractByUserId(Integer userId) {
        return contractDao.getContractByUserId(userId);
    }

    @Override
    public List<Contract> getContract(String keyword,String desId) {
        List<Contract> contractList = contractDao.getContract(keyword,desId);
        return contractList;
    }

    @Override
    public Integer count(String desId) {
        Integer count = contractDao.count(desId);
        return count;
    }
}
